/*
 * @lc app=leetcode.cn id=1232 lang=javascript
 *
 * [1232] 缀点成线
 */

// @lc code=start
/**
 * @param {number[][]} coordinates
 * @return {boolean}
 */
var checkStraightLine = function (coordinates) {
  if (coordinates.length === 2) {
    return true;
  }
  for (let i = 2; i < coordinates.length; i++) {
    const [x1, y1] = coordinates[i - 2];
    const [x2, y2] = coordinates[i - 1];
    const [x3, y3] = coordinates[i];
    if ((y3 - y1) * (x2 - x1) - (y2 - y1) * (x3 - x1) !== 0) {
      return false;
    }
  }
  return true;
};
// @lc code=end
